<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Code extends Model
{
    //随机获取验证问题
    public function getRand()
    {
        $code = Code::orderBy(\DB::raw('RAND()'))
            ->first();
        session(['answer'=>$code->answer]);
        return $code;
    }
}
